<template>
  <div class="el-full el-box-column">
    <el-tabs class="el-tabs-bg el-box-column el-flex el-tabs-flex" v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="任务详情" name="first" style="overflow: auto;">
        <el-form label-width="150px" :model="formData">
          <el-form-item label="任务类型：">
            <el-col :span="7">
              <span>{{formData.taskCat}}</span>
            </el-col>
          </el-form-item>
          <el-form-item label="任务编码：">
            <el-col :span="7">
              <span>{{formData.taskCode}}</span>
            </el-col>
          </el-form-item>
          <el-form-item label="要求完成时间：">
            <el-col :span="7">
              <span>{{formData.expirationDate}}</span>
            </el-col>
          </el-form-item>
          <el-form-item label="任务内容：">
            <el-col :span="18">
              <span>{{formData.taskContent}}</span>
            </el-col>
          </el-form-item>
          <el-form-item label="备注：">
            <el-col :span="7">
              <span>{{formData.taskDesc}}</span>
            </el-col>
          </el-form-item>
          <el-form-item label="发布人：">
            <el-col :span="7">
              <span>{{formData.issuer}}</span>
            </el-col>
          </el-form-item>
          <el-form-item label="发布时间：">
            <el-col :span="7">
              <span>{{formData.issueDate}}</span>
            </el-col>
          </el-form-item>
          <el-form-item label="责任人：">
            <el-col :span="7">
              <span>{{formData.principal}}</span>
            </el-col>
          </el-form-item>
          <el-form-item label="协助人：">
            <el-col :span="7">
              <span>{{formData.assistPerson}}</span>
            </el-col>
          </el-form-item>
          <el-form-item label="知会人：">
            <el-col :span="7">
              <span>{{formData.notifyPerson}}</span>
            </el-col>
          </el-form-item>
          <el-form-item label="附件：">
            <el-col :span="7">
              <el-upload :disabled='true' :class="justLook=='Y'?'upload-close-pic':'handle-upload'" action="/api/ccms/attachment/uploadByBusiness"
                :on-preview="handlePreview" :before-remove="beforeRemove" multiple :limit="10" :data="fileData"
                :on-exceed="handleExceed" :file-list="fileList" v-model="enclosures.files" ref="upload" :on-success="onSuccess"
                :on-error="onError" :auto-upload="false" :before-upload="beforeAvatarUpload" :headers="{Authorization: this.Authorization}"
                :on-remove="onRemove">
              </el-upload>
            </el-col>
          </el-form-item>
        </el-form>
        <el-card class="box-card" style="overflow: auto;box-shadow: none;">
          <div slot="header" class="clearfix">
            <span>子任务列表：</span>
            <el-button type="primary" v-if="showTab =='我负责的' && formData.taskStatusName == '办理中'&&justLook=='N'" plain
              style="float: right;" @click='handleTaskAdd(formData)'>新增<i class="el-icon-plus"></i></el-button>
          </div>
          <div class="text item">
            <el-table :data="tableData" border stripe>
              <el-table-column type="index" align="center" label="序号" min-width="55px" sortable :show-overflow-tooltip="true"></el-table-column>
              <el-table-column prop="taskCode" label="任务编码" min-width="115px" sortable :show-overflow-tooltip="true"></el-table-column>
              <el-table-column prop="taskContent" align="center" label="任务内容" min-width="115px" sortable
                :show-overflow-tooltip="true"></el-table-column>
              <el-table-column prop="taskStatusName" align="center" label="任务状态" min-width="95px" sortable
                :show-overflow-tooltip="true"></el-table-column>
              <el-table-column prop="principal" align="center" label="负责人" min-width="95px" sortable
                :show-overflow-tooltip="true"></el-table-column>
              <el-table-column prop="issueDate" align="center" label="发布日期" min-width="115px" sortable
                :show-overflow-tooltip="true"></el-table-column>
              <el-table-column prop="expirationDate" align="center" label="要求完成日期" min-width="115px" sortable
                :show-overflow-tooltip="true"></el-table-column>
              <el-table-column label="操作" width="190px" sortable align="center" fixed="right">
                <template slot-scope="scope">
                  <el-button class="td-btn-icon" type="text" title="查看" @click='handleDetails(scope.$index, scope.row)'
                    icon="el-icon-zoom-in"></el-button>
                  <el-button class="td-btn-icon" type="text" title="编辑" :disabled='scope.row.taskStatusName !="起草"'
                    @click='handleTaskEdit(scope.$index, scope.row)' icon="el-icon-edit"></el-button>
                  <el-button class="td-btn-icon" type="text" title="发布" :disabled='scope.row.taskStatusName !="起草"'
                    @click='handleTaskRelease(scope.$index, scope.row)' icon="el-icon-position"></el-button>
                  <el-button class="td-btn-icon" type="text" title="删除" :disabled='scope.row.taskStatusName !="起草"'
                    @click.native.prevent="deleteChild(scope.$index, scope.row)" icon="el-icon-delete"></el-button>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </el-card>
      </el-tab-pane>
      <el-tab-pane class="el-flex el-box-column" label="进度反馈" name="second" lazy>
        <el-row>
          <el-button plain type="primary" @click='progressAdd' style="float: right;margin-bottom: 10px;" v-if="showTab =='我负责的' && formData.taskStatusName == '办理中'&&justLook == 'N'"
            class="el-button-pad">新增<i class="el-icon-plus el-icon--right"></i>
          </el-button>
        </el-row>
        <el-table ref="firstTale" :data="taskFeedbackTab" border stripe height="100%" style="width: 100%">
          <el-table-column type="index" align="center" label="序号" min-width="55px" sortable :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="creationDate" align="center" label="反馈日期" min-width="115px" sortable
            :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="createdByName" label="反馈人" min-width="95px" sortable :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="feedbackContent" align="left" label="反馈内容" min-width="115px" sortable :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="feedbackStatusName" align="center" label="状态" min-width="95px" sortable :show-overflow-tooltip="true"></el-table-column>
          <el-table-column label="操作" width="150px" sortable align="center" fixed="right" v-if="showTab =='我负责的'">
            <template slot-scope="scope">
              <el-button class="td-btn-icon" type="text" title="提交" :disabled='scope.row.feedbackStatusName =="已提交"'
                icon="el-icon-circle-check" @click="feedbackSubRow(scope.$index, scope.row)"></el-button>
              <el-button class="td-btn-icon" type="text" title="编辑" :disabled='scope.row.feedbackStatusName =="已提交"'
                @click='progressAdd(scope.$index, scope.row)' icon="el-icon-edit"></el-button>
              <el-button class="td-btn-icon" type="text" title="删除" :disabled='scope.row.feedbackStatusName =="已提交"' @click.native.prevent="feedbackDelRow(scope.$index, scope.row)"
                icon="el-icon-delete"></el-button>
            </template>
          </el-table-column>
        </el-table>
        <el-form label-width="45px" class='file-upload-style' v-if="formData.taskStatusName == '办理中'&&(justLook=='N'||gettaskFeedbackDown=='Y')">
          <el-form-item label="附件:">
            <el-col :span='7'>
              <el-upload :disabled="justLook=='N'?false:true" action="/api/ccms/attachment/uploadByBusiness" :before-remove="beforeRemove" :class="justLook=='Y'?'upload-close-button':''"
                :data="{
                  businessId: this.formData.taskId,
                  bigCatId: '任务管理',
                  smallCatId: '进度反馈',
                } "
                multiple :on-exceed="handleExceed" :file-list="fileListSecond" :headers="{Authorization: this.Authorization}"
                :on-remove="onRemove">
                <el-button size="small" type="primary" v-if="showTab =='我负责的' && formData.taskStatusName == '办理中'&&justLook == 'N'">点击上传</el-button>
              </el-upload>
            </el-col>
          </el-form-item>
        </el-form>
      </el-tab-pane>
      <el-tab-pane class="el-flex el-box-column" label="完成结果" name="third" height="100%" style="width: 100%">
        <el-row>
          <el-button plain type="primary" @click='resultAdd' style="float: right;margin-bottom: 10px;" v-if="showTab =='我负责的'"
            class="el-button-pad">新增<i class="el-icon-plus el-icon--right"></i>
          </el-button>
        </el-row>
        <el-table ref="firstTale" :data="taskResultTab" border stripe>
          <el-table-column type="index" align="center" label="序号" min-width="55px" sortable :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="creationDate" align="center" label="创建日期" min-width="115px" sortable
            :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="resultContent" align="left" label="完成结果" min-width="115px" sortable :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="resultStatusName" align="center" label="状态" min-width="95px" sortable :show-overflow-tooltip="true"></el-table-column>
          <el-table-column label="操作" width="150px" sortable align="center" fixed="right" v-if="showTab =='我负责的'">
            <template slot-scope="scope">
              <el-button class="td-btn-icon" type="text" title="提交" :disabled='scope.row.resultStatusName =="已提交"' icon="el-icon-circle-check"
                @click="resultSubRow(scope.$index, scope.row)"></el-button>
              <el-button class="td-btn-icon" type="text" title="编辑" :disabled='scope.row.resultStatusName =="已提交"'
                @click='resultAdd' icon="el-icon-edit"></el-button>
              <el-button class="td-btn-icon" type="text" title="删除" :disabled='scope.row.resultStatusName =="已提交"' @click.native.prevent="resultDelRow(scope.$index, scope.row)"
                icon="el-icon-delete"></el-button>
            </template>
          </el-table-column>
        </el-table>
        <el-form label-width="45px" class='file-upload-style' v-if="formData.taskStatusName == '办理中'&&(justLook == 'N'||gettaskResultDown=='Y')">
          <el-form-item label="附件:">
            <el-col :span='7'>
              <el-upload :disabled="justLook=='N'?false:true" action="/api/ccms/attachment/uploadByBusiness" :before-remove="beforeRemove" :class="justLook=='Y'?'upload-close-button':''"
                :data="{
                  businessId: this.formData.taskId,
                  bigCatId:'任务管理',
                  smallCatId: '完成结果',
                } "
                multiple :on-exceed="handleExceed" :file-list="fileListThird" :headers="{Authorization: this.Authorization}"
                :on-remove="onRemove">
                <el-button size="small" type="primary" v-if="showTab =='我负责的' && formData.taskStatusName == '办理中'&&justLook == 'N'">点击上传</el-button>
              </el-upload>
            </el-col>
          </el-form-item>
        </el-form>
      </el-tab-pane>
      <div style="text-align: right;margin-bottom: 8px;margin-right: 8px;">
        <el-button type="primary" v-if="showTab =='我创建的'&&justLook != 'Y'" @click="Transferred(formData)">办结 <i class="el-icon-circle-check"></i></el-button>
        <el-button type="danger" v-if="showTab =='我创建的'&&justLook != 'Y'" @click="Termination(formData)">终止 <i class="el-icon-circle-close"></i></el-button>
        <el-button type="primary" v-if="showTab =='我负责的' && formData.taskStatusName == '已发布'&&justLook == 'N'" @click="receive(formData)">接收
          <i class="el-icon-circle-check"></i>
        </el-button>
        <el-button type="danger" v-if="showTab =='我负责的' && formData.taskStatusName == '已发布'&&justLook == 'N'" @click="rejection(formData)">拒收
          <i class="el-icon-circle-close"></i>
        </el-button>
        <el-button type="danger" @click='goBack'>关闭 <i class="el-icon-document-checked el-icon-close"></i></el-button>
      </div>
    </el-tabs>

    <el-dialog :title="addTitle" :visible.sync="dialogVisible" width="30%" :before-close="handleClose">
      <el-form>
        <el-input placeholder="请输入" v-model="formText.textarea" type="textarea"></el-input>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="addFormData(formText)">确定 <i class="el-icon-document-checked"></i>
        </el-button>
        <el-button @click="dialogVisible = false;formText.textarea = ''">取消 <i class="el-icon-refresh-left"></i></el-button>
      </span>
    </el-dialog>
  </div>

</template>

<script>
  import {
    Tree,
    Dialog,
    Table,
    TableColumn,
    Pagination,
    MessageBox,
    Message,
    Drawer,
    Tabs,
    TabPane,
    Upload
  } from 'element-ui'
  import {
    getTaskData, //获取详情
    taskFeedback, //反馈列表
    taskResult, //完成结果列表
    taskStatus, //更改任务状态
    findAttchList, //获取文件
    taskDel, //删除子任务
    taskFeedbackAdd, //新增反馈内容
    taskFeedbackUpdata, //修改反馈内容
    getTaskFeedback, //获取反馈详情
    taskFeedbackSubmit, //提交反馈
    taskFeedbackDel, //删除反馈内容
    taskResultAdd, //新增完成结果
    taskResultUpdata, //修改完成结果
    getTaskResult, //获取完成详情
    taskResultSubmit, //提交完成结果
    taskResultDel, //删除完成结果
    acceptingStatus, //办理
    removeFiles
  } from '@/api/missionCenter/missionCenter.js'
  import CreateTask from './createTask.vue'
  export default {
    name: 'handleDetails',
    components: {
      'el-tree': Tree, // 树形菜单
      'el-dialog': Dialog, // 对话框
      'el-table': Table, // 表格
      'el-table-column': TableColumn, // 表格列
      'el-pagination': Pagination, // 分页
      'el-drawer': Drawer, // 抽屉
      'el-tabs': Tabs, // 标签页
      'el-tab-pane': TabPane, // 标签页列
      "el-upload": Upload, //上传
      CreateTask //详情模块
    },
    data() {
      var dataList = {}
      return {
        gettaskResultDown:'N',
        gettaskFeedbackDown:'N',
        justLook: 'Y',
        Authorization: '',
        activeName: 'first', //选项卡默认第一个
        addTitle: '', //弹框标题
        dialogVisible: false,

        formData: {},
        fileList: [],
        fileListSecond: [],
        fileListThird: [],
        fileData: {
          bigCatName: '',
          smallCatName: '',
          businessId: ''
        },
        enclosures: JSON.parse(JSON.stringify(dataList)),
        row: {},
        tableData: [], //子列表
        taskFeedbackTab: [], //进度反馈
        taskResultTab: [], //完成结果
        showTab: '',
        data: [],
        formText: {
          textarea: '',
        },
        feedbackId: '',
        resultId: '',
      }
    },
    created() {
      if (this.$route.params.row) {
        let formData = this.$route.params.row
        this.showTab = formData.showTab
        this.justLook = this.$route.params.row.justLook
        this.taskTabel(formData.taskId)
      } else if (sessionStorage.lookTaskId) {
        this.showTab = sessionStorage.lookshowTab
        this.taskTabel(sessionStorage.lookTaskId)
        this.justLook = sessionStorage.justLook
      }
      this.Authorization = this.getCookie('Authorization')
      this.fileData.sysCode = this.getCookie('sysCode')
    },
    methods: {
      getCookie(cname) {
        var name = cname + "="
        var ca = document.cookie.split(';')
        for (var i = 0; i < ca.length; i++) {
          var c = ca[i].trim()
          if (c.indexOf(name) == 0) return c.substring(name.length, c.length)
        }
        return ""
      },
      goBack() { //返回
        this.$router.go(-1)
      },
      //获取详情
      taskTabel(id) {
        console.log(id)
        getTaskData(id).then((res) => {
          if (res.data.code == 10000) {

            this.formData = res.data.data
            this.tableData = this.formData.childTaskList
            let assistNameList = []
            this.formData.assistPersonList.forEach(e => {
              e.personName = e.personName
              assistNameList.push(e.personName)
            })
            this.formData.assistPerson = assistNameList.join(' ')

            let notifyNameList = []
            this.formData.notifyPersonList.forEach(e => {
              e.personName = e.personName
              notifyNameList.push(e.personName)
            })
            this.formData.notifyPerson = notifyNameList.join(' ')
            if (this.formData.taskCat == '8af08c3bee5c46f793cf1a86c7d00952') {
              this.formData.taskCat = '年度重点工作'
            } else if (this.formData.taskCat == 'ee31a14dd08e4937b8b644d426a9905b') {
              this.formData.taskCat = '年度决策-年度会议工作'
            } else if (this.formData.taskCat == 'c9f1e1bd6bbd448da9bc234b37f2c75c') {
              this.formData.taskCat = '党政领导联席会'
            } else if (this.formData.taskCat == '1adaf3a71962459392b40301e88d91e0') {
              this.formData.taskCat = '总经理办公室'
            } else if (this.formData.taskCat == '26231877e454429182eafb69771e2f9e') {
              this.formData.taskCat = '领导交办'
            } else if (this.formData.taskCat == '8af9dbfd21424e83a7acdfad2784c524') {
              this.formData.taskCat = '长期关注事项'
            } else if (this.formData.taskCat == '7e97febf4ab34ebf9df1e80cce15d866') {
              this.formData.taskCat = '重要文件'
            } else if (this.formData.taskCat == '42c38956442944be8ec65da6546cfc0e') {
              this.formData.taskCat = '周例会'
            }
            findAttchList({
              businessId: id,
              smallCatName: '附件'
            }).then((res) => {
              if (res.data.code == 10000) {
                this.fileList = res.data.data.records
                this.fileList.forEach(e => {
                  e.name = e.attFullName
                })
              }
            })
          }
        })
      },
      //进度反馈列表
      gettaskFeedback(id) {
        taskFeedback(id).then((res) => {
          if (res.data.code == 10000) {
            this.taskFeedbackTab = res.data.data.records
            findAttchList({
              businessId: id,
              smallCatName: '进度反馈'
            }).then((res) => {
              if (res.data.code == 10000) {
                  if(res.data.data.records.length==0){
                  this.gettaskFeedbackDown='N'
                }else{
                  this.gettaskFeedbackDown='Y'
                }
                this.fileListSecond = res.data.data.records
                this.fileListSecond.forEach(e => {
                  e.name = e.attFullName
                })
              }
            })
          }
        })
      },
      //完成结果列表
      gettaskResult(id) {
        taskResult(id).then((res) => {
          if (res.data.code == 10000) {
            this.taskResultTab = res.data.data.records
            findAttchList({
              businessId: id,
              smallCatName: '完成结果'
            }).then((res) => {
              if (res.data.code == 10000) {
                 if(res.data.data.records.length==0){
                  this.gettaskResultDown='N'
                }else{
                  this.gettaskResultDown='Y'
                }
                this.fileListThird = res.data.data.records
                this.fileListThird.forEach(e => {
                  e.name = e.attFullName
                })
              }
            })
          }
        })
      },
      handleClick(tab, event) {
        if (tab.label == '进度反馈') {
          this.gettaskFeedback(this.formData.taskId)
        } else if (tab.label == '完成结果') {
          this.gettaskResult(this.formData.taskId)
        }
      },
      handleClose(done) {
        done();
      },
      progressAdd(index, row) { //进度反馈新增
        this.addTitle = '反馈内容'
        this.formText.textarea = ''
        this.feedbackId = ''
        this.dialogVisible = true;
        console.log(row)
        if (row) {
          this.formText.textarea = row.feedbackContent;
          this.feedbackId = row.feedbackId
        }
      },
      resultAdd(index, row) { //完成结果新增
        this.addTitle = '完成结果'
        this.formText.textarea = ''
        this.dialogVisible = true
        if (row) {
          this.formText.textarea = row.resultContent;
          this.resultId = row.resultId
        }
      },
      //新增反馈和结果addTitle
      addFormData(text) {
        if (this.addTitle == '反馈内容') {
          if (!this.feedbackId) {
            taskFeedbackAdd({
              feedbackContent: this.formText.textarea,
              feedbackStatus: 'bc743cf20a564de9bf3b5fed9ac6915f',
              taskId: this.formData.taskId
            }).then((res) => {
              if (res.data.code == 10000) {
                Message({
                  type: 'success',
                  message: "新增成功"
                });
                this.dialogVisible = false;
                //this.gettaskFeedback(this.formData.taskId)
                  taskFeedback(this.formData.taskId).then((res) => {
                    if (res.data.code == 10000) {
                      this.taskFeedbackTab = res.data.data.records
                    }
                  })
              }
            })
          } else {
            taskFeedbackUpdata({
              feedbackContent: this.formText.textarea,
              feedbackStatus: 'bc743cf20a564de9bf3b5fed9ac6915f',
              taskId: this.formData.taskId,
              feedbackId: this.feedbackId
            }).then((res) => {
              Message({
                type: 'success',
                message: "修改成功"
              });
              this.dialogVisible = false;
              //this.gettaskFeedback(this.formData.taskId)
              taskFeedback(this.formData.taskId).then((res) => {
                if (res.data.code == 10000) {
                  this.taskFeedbackTab = res.data.data.records
                }
              })
            })
          }
        } else if (this.addTitle == '完成结果') {
          if (!this.resultId) {
            taskResultAdd({
              resultContent: this.formText.textarea,
              resultStatus: 'bc743cf20a564de9bf3b5fed9ac6915f',
              taskId: this.formData.taskId,
            }).then((res) => {
              if (res.data.code == 10000) {
                Message({
                  type: 'success',
                  message: "新增成功"
                });
                this.dialogVisible = false;
               // this.gettaskResult(this.formData.taskId)

                 taskResult(this.formData.taskId).then((res) => {
                   if (res.data.code == 10000) {
                     this.taskResultTab = res.data.data.records
                   }
                 })
              }
            })
          } else {
            taskResultUpdata({
              resultContent: this.formText.textarea,
              resultStatus: 'bc743cf20a564de9bf3b5fed9ac6915f',
              taskId: this.formData.taskId,
              resultId: this.resultId
            }).then((res) => {
              if (res.data.code == 10000) {
                Message({
                  type: 'success',
                  message: "修改成功"
                });
                this.dialogVisible = false;
                //this.gettaskResult(this.formData.taskId)
                taskResult(this.formData.taskId).then((res) => {
                  if (res.data.code == 10000) {
                    this.taskResultTab = res.data.data.records
                  }
                })
              }
            })
          }
        }
      },
      //子列表删除
      deleteChild(index, row) {
        var id = row.taskId
        MessageBox.confirm('您是否确定删除选中内容', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          })
          .then(() => {
            taskDel(id).then(res => {
              if (res.data.code == 10000) {
                Message({
                  type: 'success',
                  message: '删除成功'
                });
                this.getTabTree(this.formInline)
              }

            }).catch(res => {
              Message({
                type: 'warning',
                message: "删除失败"
              });
            })
          })
      },
      //反馈提交
      feedbackSubRow(index, row) {
        taskFeedbackSubmit(row.feedbackId).then((res) => {
          if (res.data.code == 10000) {
            Message({
              type: 'success',
              message: "提交成功"
            });
            //this.gettaskFeedback(this.formData.taskId)
            taskFeedback(this.formData.taskId).then((res) => {
              if (res.data.code == 10000) {
                this.taskFeedbackTab = res.data.data.records
              }
            })
          }
        })
      },
      //反馈删除
      feedbackDelRow(index, row) {
        MessageBox.confirm('您是否确定删除选中内容', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          taskFeedbackDel(row.feedbackId).then((res) => {
            if (res.data.code == 10000) {
              Message({
                type: 'success',
                message: "删除成功"
              });
             // this.gettaskFeedback(this.formData.taskId)
             taskFeedback(this.formData.taskId).then((res) => {
               if (res.data.code == 10000) {
                 this.taskFeedbackTab = res.data.data.records
               }
             })
            }
          })
        })
      },
      //完成结果提交
      resultSubRow(index, row) {
        taskResultSubmit(row.resultId).then((res) => {
          if (res.data.code == 10000) {
            Message({
              type: 'success',
              message: "提交成功"
            });
            //this.gettaskResult(this.formData.taskId)
            taskResult(this.formData.taskId).then((res) => {
              if (res.data.code == 10000) {
                this.taskResultTab = res.data.data.records
              }
            })
          }
        })
      },
      //完成结果删除
      resultDelRow(index, row) {
        taskResultDel(row.resultId).then((res) => {
          if (res.data.code == 10000) {
            Message({
              type: 'success',
              message: "删除成功"
            });
            //this.gettaskResult(this.formData.taskId)
            taskResult(this.formData.taskId).then((res) => {
              if (res.data.code == 10000) {
                this.taskResultTab = res.data.data.records
              }
            })
          }
        })
      },
      handleTaskEdit(index, row) {
        // row.formTitle = '编辑任务'
        row.justLook = 'N'
        this.handleTask(row.taskId)
      },
      handleTaskAdd(row) {
        console.log(row)
        // row.formTitle = '创建任务'
        this.handleTask(row)
        // this.giveFuncEvt('object')
      },
      handleTask(row) { //创建任务动态路由跳转
        //this.multiRouters是全局提供的自动添加多级路由的方法
        this.$router.addRoutes(this.multiRouters([{
          path: 'createTask',
          name: 'createTask', //自定义name名称
          component: () => import('@/views/thematicPortal/missionCenter/createTask'),
          meta: {
            title: '创建任务'
          }
        }]));
        this.$router.push(this.routerMatch({
          name: "createTask", //顶部导航+侧边导航
          params: {
            row: row
          }
        }))
      },
      handleDetails(index, row) {
        row.justLook = 'Y'
        console.log(row);
        sessionStorage.taskId = row.taskId;
        sessionStorage.showTab = sessionStorage.lookshowTab;
        row.showTab = sessionStorage.lookshowTab
        //this.multiRouters是全局提供的自动添加多级路由的方法
        // row.showTab = '我创建的'
        this.$router.addRoutes(this.multiRouters([{
          path: 'handleDetails',
          name: 'handleDetails', //自定义name名称
          component: () => import('@/views/thematicPortal/missionCenter/handleDetails'),
          meta: {
            title: '办理'
          }
        }]));
        this.$router.push(this.routerMatch({
          name: "handleDetails", //顶部导航+侧边导航
          params: {
            row: row
          }
        }))
      },
      //发布按钮
      handleTaskRelease(index, row) {
        taskStatus(row.taskId, 'c2cd78d1eea54923970dfdcf5898ce92').then((res) => {
          if (res.data.code == 10000) {
            Message({
              type: 'success',
              message: "发布成功"
            });
            this.taskTabel(formData.taskId)
          }
        })
      },
      //删除确认
      beforeRemove(file, fileList) {
        return MessageBox.confirm(`确定移除 ${ file.name }？`)
      },
      onRemove(file, fileList) { //附件删除
        if (!file.attId) {
          Message.success('附件移除成功')
        } else {
          removeFiles(file.attId).then(res => {
            if (res.data.code == 10000) {
              Message.success('附件移除成功')
            }
          })
        }
      },
      //点击文件获取文件信息
      handlePreview(file) {
        console.log(file)
      },
      //控制文件个数
      handleExceed(files, fileList) {
        this.$message.warning(`当前限制选择 10 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`)
      },
      beforeAvatarUpload(file) {
        console.log(file)
        if (!file) {
          Message.warning("请选择需要导入的模板！")
          return
        }
      },
      onSuccess(res) {
        // console.log(res)
        if (res.code === 10000) {
          Message.success('上传成功')
          this.handleAattachClose()
          console.log('成功', res)
        }
      },
      // 文件上传(提交)接口失败
      onError(err) {
        Message.error('上传失败')
        console.log('失败', err)
      },
      //办结
      Transferred(row) {
        console.log(row)
        taskStatus(row.taskId, '7b622176258245d6bb7ea0f3541845ba').then((res) => {
          if (res.data.code == 10000) {
            Message({
              type: 'success',
              message: "操作成功"
            })
            this.$router.go(-1)
          }
        })
      },
      //终止
      Termination(row) {
        console.log(row)
        taskStatus(row.taskId, 'a3bcf69d7e7c4572a3c0f7cefbb26432').then((res) => {
          if (res.data.code == 10000) {
            Message({
              type: 'success',
              message: "操作成功"
            })
            this.$router.go(-1)
          }
        })
      },
      //接收
      receive(row) {
        acceptingStatus(row.taskId, 'b834147cb5b34e1db80a7cb92dbe6869').then((res) => {
          if (res.data.code == 10000) {
            Message({
              type: 'success',
              message: "操作成功"
            })
            this.$router.go(-1)
          }
        })
      },
      //拒收
      rejection(row) {
        acceptingStatus(row.taskId, '9f1a00d46cb042cb94b44fdda423dfc4').then((res) => {
          if (res.data.code == 10000) {
            Message({
              type: 'success',
              message: "操作成功"
            })
            this.$router.go(-1)
          }
        })
      }
    }
  }
</script>
<style lang="scss">
  .file-upload-style {
    margin-top: 10px
  }
 .el-upload-list__item {
    transition: none;
  }
  .handle-upload {
    .el-upload-list__item:first-child {
      margin-top: -25px;
    }
  }

  .upload-close-pic {
    .el-upload-list__item:first-child {
      margin-top: -25px;
    }

    .el-upload-list__item:hover .el-icon-close {
      display: none;

    }
     .el-upload-list__item:hover .el-icon-close-tip {
      display: none;
      opacity: 0;
    }
  }

  .upload-close-button {
    .el-upload-list__item:first-child {
      margin-top: -25px;
    }
    .el-upload-list__item:hover .el-icon-close  {
      display: none;
    }
    .el-upload-list__item:hover .el-icon-close-tip {
      display: none;
      opacity: 0;
    }
  }
</style>
